package com.kfm.jdbc.day0405;

import java.util.concurrent.ArrayBlockingQueue;
import java.util.concurrent.TimeUnit;

public class Demo03 {

    public static void main(String[] args) {
        ArrayBlockingQueue<String> queue = new ArrayBlockingQueue<>(1);

        try {
            queue.offer("a");
            System.out.println(queue);
//            System.out.println(queue.take()); // a
            queue.offer("b", 3, TimeUnit.SECONDS); // 超时等待
            System.out.println(queue);
        } catch (InterruptedException e) {
            throw new RuntimeException(e);
        }
    }
}
